package demo.IOStream;

import java.io.*;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/15-08-15-19:49
 * @Description：demo.IOStream
 */
public class BufferFileCopy {
    public static void main(String[] args) {
        BufferedReader reader = null;
        BufferedWriter writer = null;
        try {
//            reader = new BufferedReader(new FileReader(new File("D:\\qq文件\\jjy2.jpg")));
//            writer = new BufferedWriter(new FileWriter(new File(".\\jjy2.jpg")));
            reader = new BufferedReader(new FileReader(new File("calcCharNum.txt")));
            writer = new BufferedWriter(new FileWriter(new File("cal.txt")));
            char[] c = new char[1024];
            int len = -1;
            while((len = reader.read(c)) != -1){
                writer.write(c,0,len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                if(reader != null){
                    reader.close();
                }
                if(writer != null){
                    writer.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
